package com.cyl.cue.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.cyl.cue.domain.TCueInfo;
import com.cyl.cue.service.ITCueInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 球杆信息管理Controller
 * 
 * @author ruoyi
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/cue/cueInfo")
public class TCueInfoController extends BaseController
{
    @Autowired
    private ITCueInfoService tCueInfoService;

    /**
     * 查询球杆信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCueInfo tCueInfo)
    {
        startPage();
        List<TCueInfo> list = tCueInfoService.selectTCueInfoList(tCueInfo);
        return getDataTable(list);
    }

    /**
     * 导出球杆信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:export')")
    @Log(title = "球杆信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCueInfo tCueInfo)
    {
        List<TCueInfo> list = tCueInfoService.selectTCueInfoList(tCueInfo);
        ExcelUtil<TCueInfo> util = new ExcelUtil<TCueInfo>(TCueInfo.class);
        try {
            util.exportExcel(response, list, "球杆信息管理数据");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取球杆信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tCueInfoService.selectTCueInfoById(id));
    }

    /**
     * 新增球杆信息管理
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:add')")
    @Log(title = "球杆信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCueInfo tCueInfo)
    {
        return toAjax(tCueInfoService.insertTCueInfo(tCueInfo));
    }

    /**
     * 修改球杆信息管理
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:edit')")
    @Log(title = "球杆信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCueInfo tCueInfo)
    {
        return toAjax(tCueInfoService.updateTCueInfo(tCueInfo));
    }

    /**
     * 删除球杆信息管理
     */
    @PreAuthorize("@ss.hasPermi('cue:cueInfo:remove')")
    @Log(title = "球杆信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCueInfoService.deleteTCueInfoByIds(ids));
    }


    /**
     * 获取球杆信息管理详细信息
     */
    @GetMapping(value = "/getInfoByAntiCounterfeitingNumber/{antiCounterfeitingNumber}")
    public AjaxResult getInfoByAntiCounterfeitingNumber(@PathVariable("antiCounterfeitingNumber") String antiCounterfeitingNumber)
    {
        return success(tCueInfoService.selectTCueInfoByAntiCounterfeitingNumber(antiCounterfeitingNumber));
    }

}
